package subject_set.weekly_competition.day10_1;

import java.util.ArrayList;
import java.util.List;

/**
 * @author haomin
 * @date 2022/10/01 22:29
 **/
public class Num2 {
    class Solution1 {
        public int xorAllNums(int[] nums1, int[] nums2) {
            List<Long> list = new ArrayList<>();
            for(int i = 0; i < nums1.length; ++i){
                for(int j = 0; j < nums2.length; ++j){
                    list.add((long) (nums1[i] ^ nums2[j]));
                }
            }
            long res = 0;
            for (Long aLong : list) {
                res ^= aLong;
            }
            return (int)res;
        }
    }
    class Solution {
        public int xorAllNums(int[] nums1, int[] nums2) {
            int res1 = 0;
            int res2 = 0;
            if(nums1.length % 2 == 0){
                for(int i : nums1){
                    res1 ^= i;
                }
            }
            if(nums2.length % 2 == 0){
                for(int i : nums2){
                    res2 ^= i;
                }
            }
            if(nums1.length % 2 == 0 || nums2.length % 2 != 0) return res1;
            if(nums1.length % 2 != 0 || nums2.length % 2 == 0) return res2;
            if(nums1.length % 2 == 0 || nums2.length % 2 == 0) return res1^res2;
            if(nums1.length % 2 == 0 || nums2.length % 2 == 0) return res1^res2;
            return 0;
        }
    }
    class Solution3 {
        public int xorAllNums(int[] nums1, int[] nums2) {
            int n1=nums1.length,n2=nums2.length;
            int ans=0;
            for(int a:nums1)if((n2&1) == 1)ans^=a;
            for(int a:nums2)if((n1&1) == 1)ans^=a;
            return ans;
        }
    }
}